Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching changes for URL resolver APIs #87

Merged
merged 5 commits into from
Jan 9, 2022
Merged

Caching changes for URL resolver APIs #87

merged 5 commits into from
Jan 9, 2022

Conversation

DeepDoge
Copy link
Contributor

@DeepDoge DeepDoge commented Jan 8, 2022

  • Added back manual memory cache temporarily
  • And this time its working as expected
  • Also disabled use of browser cache for now
  • Thought we are still saying browser to cache it for the future version

- added back manual memory cache temporarily
- and this time its working as expected
- also disabled use of browser cache for now
- thought we are still saying browser to cache it for the future version
@DeepDoge DeepDoge changed the title Added back memory cache temporarily Caching changes for URL resolver APIs Jan 8, 2022
@DeepDoge
Copy link
Contributor Author

DeepDoge commented Jan 8, 2022

Gonna add more commits under this.

- Told browser to not to cache the api request
- Removed manual memory cache
- Implimented caching using indexedDB
- Cache time is 1 day
@DeepDoge
Copy link
Contributor Author

DeepDoge commented Jan 9, 2022

What changed?

Since we have 2 different API options(maybe more later) to resolve YouTube IDs and they might have different caching headers or no caching headers at all, I told browser to not cache the API request and handled caching using IndexedDB. (Cache time is 1 day)

Why used IndexedDB?

  • If we used force-cache while doing API request they might not expire at all. And API might send bad or invalid or null response that we don't wanna cache forever.
  • If we used memory it's not going to be cleaned until browser or extension restarts, so it might grow and grow and grow might cause problems in some cases. And it only lives until the browser or extension restarts.
  • If we used LocalStorage and had many caches, we can't select them by expiry date so we need to go through all of the caches and check expiry date. IndexedDB let's us index the caches by expiry date which is a more elegant and a better way to find and delete expired values.

@kodxana kodxana merged commit 30b6545 into LBRYFoundation:master Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants